package com.chaos.eurekaproducer.leetCode.sort;

/**
 * @author liaopeng
 * @title: SelectSort
 * @projectName eureka-producer
 * @description: 选择排序
 * @date 2021/7/5下午6:05
 */
public class SelectSort {

    public static int[] insertSort(int[] a){
        if (a.length==0){
            return a;
        }
        for (int i =0; i < a.length; ++i) {
            int k=i;
            for (int j = k+1; j < a.length; j++) {
                if (a[j]<a[k]){
                    k=j;
                }
            }
            if (i!=k){
               int temp = a[i];
               a[i] = a[k];
               a[k] = temp;
            }
        }
        return a;
    }

    public static void main(String[] args) {
        int[] a = new int[]{3,4,6,1,2};
        int[] b = insertSort(a);
        for (int i = 0; i < b.length; i++) {
            int i1 = b[i];
            System.out.println(i1);
        }
    }
}
